package com.mobbanana.gameHelper;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.util.Log;

import org.json.JSONObject;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.Iterator;

/**
 * @Description
 * @Author imchen
 * @CreateTime 2019/10/29 15:25
 */
public class DataUtil {

    private static final String saykit = "{\"idfv\":\"e3738ac94a63535e6053a7d616fd6c42\",\"consetWasGranted\":true,\"rateAppPopupWasShowed\":true,\"isPremium\":false}";

    private static void writeContent(String content, String filePath) {
        File file = new File(filePath);
        FileOutputStream fos = null;
        try {
            fos = new FileOutputStream(file);
            fos.write(content.getBytes(Charset.forName("UTF-8")));
            fos.flush();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (fos != null) {
                try {
                    fos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public static void writeContent(JSONObject jsonObject, String filePath) {
        writeContent(jsonObject.toString(), filePath);
        Log.d("DataUtil", "writeContent: filePath: " + filePath);
    }

    public static void initGameData(final Context context) {
        try {
            initSayKitData(context);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     *  SayKit 游戏配置
     * @param context Context
     */
    private static void initSayKitData(Context context) {
        try {
            // 配置是否弹出GDPR ，评论 ，是否已经购买游戏
            String baseConfigName = "saykit.json";
            String savePath = context.getExternalFilesDir(null).getCanonicalPath() + File.separator;
            String configFileName = "saykit_tmtrgra_" + GameUtils.getVersionName(context);
            FileUtil.copyFileFromAsset(context, "mobbanana/game" + File.separator +
                    configFileName, savePath + configFileName);

            FileUtil.copyFileFromAsset(context, "mobbanana/game" + File.separator +
                    baseConfigName, savePath + baseConfigName);

            LogUtil.d("Copy Asset files to "+savePath);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static String getAppVersion(Context context) {
        String version = "1.0.0";
        try {
            PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
            version = packageInfo.versionName;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return version;
    }


    public static void writeXML(Context context) {
        String tagKey = "downloaded.translations.keys";
        String settingskey = "has.saved.model.for.8";
        String readLocalTag = "has.saved.model.for.translations";
        String keyList = "title.privacypolicy title.button.privacypolicy title.policy crosspromo.header title.seeothergames policy.popup.message.rodo.short policy.popup.apply policy.popup.urlButton localnotification.retention.30day.title localnotification.retention.30day.body localnotification.retention.7day.title localnotification.retention.7day.body localnotification.retention.3day.title localnotification.retention.3day.body localnotification.retention.1day.title localnotification.retention.1day.body title.play title.removeads ads.ads support.your.email support.your.message support.return support.send support.what.improve menu.unlock.blocks menu.unlock.blocks.now menu.get.extra.resources menu.get.resources menu.not.enough.resources menu.watch.ad.for.resources menu.watch.ad.to.unlock.craftable menu.watch.ads menu.footer menu.reset.world menu.save.world menu.savingworld menu.savedworld menu.options menu.apply menu.support menu.prestige loading.loading rateus.doyouenjoy rateus.ok resetworld.warning resetworld.return resetworld.apply settings.fov settings.apply settings.mode settings.mode.walk settings.mode.fly settings.viewdistance settings.time settings.time.morning settings.time.midday settings.time.dawn settings.time.night settings.quality settings.quality.low settings.quality.normal settings.quality.high settings.volume settings.volume.muted settings.volume.low settings.volume.high menu.watchads.removeads menu.watch restore.purchase.restoring restore.purchase.restored dating.proposal dating.man dating.woman dating.yes dating.no quests.description.collectresourcesany quests.description.placeblocksany quests.description.collectresourcesx quests.description.placeblocksx quests.description.mountdistance quests.description.flydistance quests.description.walkdistance quests.description.tame quests.description.petxtimes quests.description.tameofx quests.description.destroyx quests.title.placeblocksany quests.title.collectresourcesx quests.title.placeblocksx quests.title.mountdistance quests.title.flydistance quests.title.walkdistance quests.title.tame quests.title.petxtimes quests.title.tameofx quests.title.destroyx quests.title.fallx quests.completed crafting.unlock" +
                " menu.blocks menu.crafting menu.clothes menu.modes menu.fb menu.restore crafting.tounlock crafting.receive crafting.craft crafting.required menu.cancel menu.ok dance.tap dance.getready dance.faster dance.success dance.failure quests.description.unlockblocks quests.title.unlockblocks crafting.useBlock crafting.yourResources crafting.no.Items multi.single multi.multiplayer multi.join.game multi.create.game multi.search multi.room.name multi.number.of.players multi.access multi.no.matches multi.previous multi.next multi.refresh multi.delete multi.start multi.created.worlds multi.title.create.world multi.are.you.sure multi.yes multi.no multi.create.world multi.create multi.cancel multi.world.exists multi.back multi.title.create.room multi.players multi.public multi.private multi.password multi.empty.room.name mult.wrong.password multi.enter.password multi.join multi.connection.error multi.exit.to.menu multi.ok multi.disconnect multi.room.creation.error multi.random multi.pregenerated quests.description.reachheight quests.title.reachheight quests.description.vehicledistance quests.title.vehicledistance chatbot.explanation choose.world.last choose.world.title choose.world.warning choose.world.button.save.refuse choose.world.button.save.accept choose.world.button.new.world choose.world.button.name.create choose.world.button.name.rename choose.world.button.delete choose.world.play choose.world.question choose.world.result choose.world.question.survival choose.world.result.survival menu.change.world choose.world.question.delete choose.world.question.delete.lose quests.description.fallx quests.title.collectresourcesany quests.description.unlocksilverrod quests.description.fishxtimes quests.description.catchxfishesbeingonboat quests.description.catchxfishesbeingonmotorboat quests.description.catchlegendaryfish quests.description.catchepicfish quests.description.catchrarefish quests.description.catchmarlinfish quests.description.catchoctopusfish quests.description.catchstingrayfish quests.description.xcollectionpoints quests.title.unlocksilverrod quests.title.fishxtimes quests.title.catchxfishesbeingonboat quests.title.catchxfishesbeingonmotorboat quests.title.catchlegendaryfish quests.title.catchepicfish quests.title.catchrarefish quests.title.catchmarlinfish quests.title.catchoctopusfish quests.title.catchstingrayfish quests.title.xcollectionpoints fishing.tutorial.popup.1 fishing.tutorial.popup.2 fishing.tutorial.popup.3 fishing.tutorial.popup.4 fishing.tutorial.popup.5 fishing.tutorial.popup.6 fishing.tutorial.popup.7 fishing.tutorial.popup.8 fishing.reminder fishing.status.pull fishing.status.wait fishing.status.break fishing.status.success fishing.status.throw fishing.status.fight fishing.status.success.trash fishing.status.break.trash pet.speciality.searching pet.speciality.mountable pets.popup.hidden.message pets.popup.locked.message pets.popup.button.ok quests.description.catchxfishesbeingonyachtboat quests.description.catchxfishesbeingonfishingboat quests.description.catchxfishesbeingontouristboat didyouknow.title didyouknow.nexthint didyouknow.ok didyouknow.cancel didyouknow.0.featuredescription didyouknow.0.gotofeature didyouknow.1.featuredescription didyouknow.1.gotofeature didyouknow.2.featuredescription didyouknow.2.gotofeature didyouknow.3.featuredescription didyouknow.3.gotofeature didyouknow.4.featuredescription didyouknow.4.gotofeature didyouknow.5.featuredescription didyouknow.5.gotofeature blueprint.open.tutorial leave.isometric leave.blueprint blueprint.delete blueprint.fill blueprint.fill.multi.ads blueprint.welcome blueprint.select.crafting blueprint.choose.where chooseyourpet.title pet.name.chimpanzee pet.name.bordercollie pet.name.babyhorse pet.name.goat pet.name.cat1 pet.name.cheetah pet.name.camel pet.name.grumpycat pet.name.cat2 pet.name.cat3 pet.name.centaur pet.name.flyingunicornblue pet.name.affricanbuffalo pet.name.zebra pet.name.chicken pet.name.cow pet.name.dachshund pet.name.giraffe pet.name.deer pet.name.nyancat pet.name.doggeneric1 pet.name.doggeneric2 pet.name.elephant pet.name.fairy pet.name.fatcat pet.name.flamingo pet.name.flyingunicornpink pet.name.flyingunicornpurple pet.name.cat pet.name.frog pet.name.garfield pet.name.gazelle pet.name.germanshepherd pet.name.hellokitty pet.name.ponyrarity pet.name.hippo pet.name.catwithcheese pet.name.horse pet.name.horse1 pet.name.horse2 pet.name.horse3 pet.name.kitler pet.name.lion pet.name.lionfemale pet.name.longcat pet.name.panda pet.name.parrot pet.name.piggy pet.name.ponyapplejack pet.name.ponyfluttershy pet.name.doggeneric3 pet.name.ponypinkypie pet.name.ponyrainbowdash pet.name.ponytwilightsparkle pet.name.poodle pet.name.pussinboots pet.name.rhinoceros pet.name.sheep pet.name.tiger pet.name.turtle pet.name.unicornblue pet.name.unicornpink pet.name.unicornpurple pet.name.wolf pet.name.york pet.name.polarbear pet.name.seal pet.name.penguin pet.name.huskydog quests.title.chatxtimes quests.title.chatxpeople quests.title.talkxtimes quests.title.talkxpeople quests.title.datextimes quests.title.datexpeople quests.title.playinstrumentxtimes quests.title.swimdistance quests.title.jumpxtimes quests.title.findtreasurextimes quests.title.buyxclothes quests.title.craftany quests.title.dancextimes quests.title.craftofx quests.description.chatxtimes quests.description.chatxpeople quests.description.talkxtimes quests.description.talkxpeople quests.description.datextimes quests.description.datexpeople quests.description.playinstrumentxtimes quests.description.swimdistance quests.description.jumpxtimes quests.description.findtreasurextimes quests.description.buyxclothes quests.description.craftany quests.description.dancextimes quests.description.craftofx internet.connection.error.title internet.connection.error.body internet.cancel internet.retry ad.connection.error.body ad.connection.error.title payment.error.body payment.error.title payment.OK menu.reset.position daily.chest.notfication.1 daily.chest.notfication.2 daily.chest.notfication.3 menu.whatsnew.feature.1.19.1 menu.whatsnew.feature.1.19.2 menu.whatsnew.feature.1.19.3 tapping.tutorial.0 tapping.tutorial.1 tapping.tutorial.2 menu.cooking cooking.chapter.1 cooking.chapter.2 cooking.chapter.3 cooking.tutor.name cooking.time.left cooking.clients.left cooking.goal cooking.earnings cooking.pause cooking.resume cooking.leave cooking.ranking cooking.upgrades cooking.play cooking.day cooking.level cooking.choose.level cooking.todays.goal cooking.prestige.required cooking.restock cooking.restock.full cooking.continue cooking.day.completed cooking.level.completed cooking.level.failed cooking.complete cooking.failed cooking.goal.bonus cooking.upgrade cooking.unlocks.on.prestige cooking.watch.ad.get.coins cooking.prestige cooking.watch.ad.to.refill cooking.unlock cooking.watch.ad tomato lettuce cheese pasta meat.balls pizza.base chopping.block stove pizza.oven cooking.upgrade.speed cooking.upgrade.capacity cooking.upgrade.coins cooking.upgrade.burn_time cooking.upgrade.patience cooking.upgrade.walking_speed cooking.upgrade.tips cooking.tut.tomato cooking.tut.lettuce cooking.tut.cheese cooking.tut.pasta cooking.tut.meat.balls cooking.tut.pizza.base cooking.tut.tomato.prod.chopping.block cooking.tut.cheese.prod.chopping.block cooking.tut.lettuce.prod.chopping.block cooking.tut.meat.balls.prod.stove cooking.tut.cooked.meat.balls.chopping.block cooking.tut.pasta.prod.stove cooking.tut.pizza.base.prod.tomato.sauce cooking.tut.pizza.base.prod.grated.cheese cooking.tut.tomato.pizza.grated.cheese cooking.tut.tomato.&.cheese.pizza.chopped.lettuce cooking.tut.margherita.pizza.minced.meat cooking.tut.tomato.pizza.pizza.oven cooking.tut.cheese.pizza.pizza.oven cooking.tut.tomato.&.cheese.pizza.pizza.oven cooking.tut.margherita.pizza.pizza.oven cooking.tut.deluxe.pizza.pizza.oven cooking.tut.cooked.meat.balls.tomato.sauce cooking.tut.tomato.meat.grated.cheese cooking.tut.tomato.cheese.meat.chopped.lettuce cooking.tut.cooked.pasta.tomato.sauce cooking.tut.spaghetti.grated.cheese cooking.tut.cheese.spaghetti.cooked.meat.balls cooking.tut.spaghetti.with.meatballs.chopped.lettuce cooking.tut.give.customer cooking.tut.burn cooking.tut.trash.1 cooking.tut.trash.2 cooking.tut.trash.3 cooking.tut.trash.4 cooking.tut.trash.5 cooking.tut.trash.6 cooking.tut.recipe.1 menu.whatsnew.title tutorial.tutor.name hospital.tutorial.0 hospital.tutorial.1 hospital.tutorial.2 hospital.tutorial.3 hospital.tutorial.4 hospital.tutorial.5 hospital.tutorial.6 hospital.tutorial.7 hospital.tutorial.8 hospital.tutorial.9 hospital.tutorial.10 hospital.cured.patients hospital.cured.stars hospital.hospital.upgrades hospital.button.ranking hospital.prestige hospital.item.name.woda hospital.item.name.plastry hospital.item.name.pulsomierz hospital.item.name.stetoskop hospital.item.name.bandaze hospital.item.name.strzykawka hospital.item.name.rentgen hospital.item.name.defibrylator hospital.item.upgrade.level hospital.item.upgrade hospital.item.unlocked hospital.prestige.req hospital.status.cure hospital.minigame.popup.success hospital.minigame.popup.prestige.earned hospital.minigame.popup.money.earned hospital.minigame.popup.button.ok hospital.minigame.popup.button.reward hospital.popup.unlock.prev.item hospital.popup.fully.upgraded hospital.popup.get.coins hospital.toast.need.better.items hospital.tutorial.tutor.name progress.popup.level.up key.tutorial.up key.tutorial.left key.tutorial.down key.tutorial.right key.tutorial.remove key.tutorial.jump key.tutorial.fall key.tutorial.roatate key.tutorial.place menu.keyboardtutorial menu.rankings choose.world.max choose.world.button.ad choose.world.watch.ad daily.rewards.block daily.rewards.animal daily.rewards.skin daily.rewards.craftable daily.rewards.noads daily.rewards.day daily.rewards.title.ribbon daily.rewards.title daily.rewards.next.in daily.rewards.info daily.rewards.claim daily.rewards.claimed.ribbon daily.rewards.great daily.rewards.soft daily.rewards.hard daily.rewards.chest policy.popup.message.default blocks.energy.watch.ad.1 blocks.energy.watch.ad.2 blocks.energy.watch.ad.3 blocks.energy.refill menu.achievement achievements.maintitle achievements.inprogress achievements.claim achievements.done ach.unlocked ach.claim currency.soft.watch.ad watch.ad.unlock.block menu.shop chest.rare chest.epic chest.legendary chest.free.in chest.free.open claim.rewards.loot block.locked.chest achievements.go.to.pause achievement.title.blocks achievement.description.blocks achievement.title.blueprint achievement.description.blueprint achievement.title.clothes achievement.description.clothes achievement.title.traveled.distance achievement.description.traveled.distance achievement.title.progress achievement.description.progress achievement.title.blocks.common achievement.description.blocks.common achievement.title.blocks.rare achievement.description.blocks.rare achievement.title.blocks.legendary achievement.description.blocks.legendary achievement.title.chests.found achievement.description.chests.found achievement.title.crafted.items achievement.description.crafted.items achievement.title.npc.dance achievement.description.npc.dance achievement.title.npc.talk achievement.description.npc.talk achievement.title.npc.relationship achievement.description.npc.relationship achievement.title.npc.pet achievement.description.npc.pet achievement.title.date achievement.description.date achievement.title.gift achievement.description.gift achievement.title.relationship.stage achievement.description.relationship.stage rewards.resources rewards.common.blocks rewards.rare.blocks rewards.legendary.blocks rewards.hard chest.tutorial.0 chest.tutorial.1 chest.tutorial.2 chest.tutorial.3 chest.popup.shop chest.popup.watch free.coins.available.in shop.no.coins tutorial.play menu.get.coins menu.get.coins.confirm offerpack.popup.success.message blueprint.tutorial.0 blueprint.tutorial.1 blueprint.tutorial.2 blueprint.tutorial.3 blueprint.tutorial.tutor.name blueprint.cant.place.1 blueprint.cant.place.2 blueprint.cant.place.3 water.cant.place blueprint.cant.place.barrier fly.for.ad fly.for.hc fly.for.money fly.accept fly.permanent mcpe.steering.tutorial.text.1 mcpe.steering.tutorial.text.3 mcpe.steering.tutorial.text.4 mcpe.steering.tutorial.text.5 mcpe.steering.tutorial.text.6 mcpe.steering.tutorial.text.7 mcpe.steering.tutorial.text.9 mcpe.steering.tutorial.text.10 mcpe.steering.tutorial.text.11 mcpe.steering.tutorial.text.jump toolkit.tutorial.text.use.toolkit toolkit.tutorial.text.hold.block toolkit.tutorial.text.return.to.game toolkit.tutorial.text.select.blocks toolkit.tutorial.text.select.slot toolkit.tutorial.text.tap.block pause.time.displayer pause.time.displayer.ready blueprint.progress.unlock.for blueprint.shop.buildings blueprint.shop.decorations blueprint.shop.special blueprint.shop.need.higher.level blueprint.build blueprint.locked blueprint.speed.up blueprint.remove blueprint.limit blueprint.use menu.collection crafting.upgradeItem menu.no_avatar menu.pet.no_avatar currency.soft.no.ad soft.no.ads.cancel menu.achievements menu.player menu.pets menu.play dressup.not.enough.coins watch.ad.get.tickets progress.minigames_played progress.blueprints_finished crafted.items button.ranking level dressup.tutorial.title dressup.tutorial.cash camera.tutorial.text.1 camera.tutorial.text.2 quest.claim shop.no.gems shop.gems.to.coins currency.gems currency.coins blocks.not.enough not.enough.gems not.enough.coins blocks.pack Nature Standard Glass Wool Clay Architecture Mystery Home Environment unlock.block.category unlock.block.category.for.ad buy.for.gems coming.soon hc.bonus.1 hc.bonus.2 hc.bonus.3 hc.bonus.4 mobs.unlocked.message watch.ad buy.this.item blueprint.tutorial.text.1 blueprint.tutorial.text.2 tutorial.text.now.you.know.everything cb_bus_stop cb_kiosk cb_city_street_water_tank cb_city_tree#1 restaurant_white_small cb_tool_shop cb_city_mini_house#2 cb_clothes_shop cb_power_plant cb_meat_shop cb_grocery_store#1 cb_city_fountain cb_coffee_bar cb_kindergarden cb_city_street_mini_house#3 cb_tiny_hospital cb_drug_store cb_music_shop cb_candy_shop cb_city_street_factory cb_tiny_police_dept cb_tiny_bank cb_city_street_firestation cb_library cb_city_street_house#7 cb_china_restaurant cb_city_street_house#9 cb_city_street_hospital cb_bar cb_electronic_shop cb_pizza_restaurant cb_medium_museum cb_medium_town_house_white love_vamp_house#2 cb_great_town_house_blue sea_hotel girls_car_block#2 cb_great_police_dept cb_girls_car_market cb_great_bank ny_tower_2 cb_great_city_hall moscow_town_house tokyo_mecha Lighthouse Car_Mechanic_Big_Sign CB_Bus_Stop CB_Kiosk CB_City_Street_Water_Tank CB_City_Tree#1 CB_Tool_Shop CB_City_Mini_House#2 CB_Clothes_Shop CB_Power_Plant Tokyo_Mecha CB_Meat_Shop CB_Grocery_Store#1 CB_City_Fountain CB_Coffee_Bar CB_Kindergarden CB_City_Street_Mini_House#3 CB_Tiny_Hospital CB_Drug_Store CB_Music_Shop CB_Candy_Shop CB_City_Street_Factory CB_Tiny_Police_Dept CB_Tiny_Bank CB_City_Street_FireStation CB_Library CB_City_Street_House#7 CB_China_Restaurant CB_City_Street_House#9 CB_City_Street_Hospital CB_Bar CB_Electronic_Shop CB_pizza_restaurant CB_Medium_Museum CB_Medium_Town_House_White Love_Vamp_House#2 CB_Great_Town_House_Blue Sea_Hotel Girls_Car_Block#2 CB_Great_Police_Dept CB_Girls_Car_Market CB_Great_Bank NY_Tower_2 CB_Great_City_Hall Moscow_Town_House tutorial.skip Port_Kiosk Port_Fisherman_House Port_Beach_Bar Port_Tree Port_Fish_Bar#2 Port_Fish_Bar#1 Port_Fish_Bar#3 Port_Lifegurard_Tower Port_Beach_House Port_Hotel Port_Town_House tutorial.title subscription.upper.text subscription.start subscription.price subscription.long.text claim.rewards.subscription per.day reward.TempFreeFlying reward.TempNoAds reward.TempUnlimitedBlocks reward.soft reward.flying.timed reward.hard currency.reward.soft currency.reward.hard builder.season.ends.in builder.daily.challenges builder.active.challenges builder.daily.refresh builder.has.golden.ticket builder.buy.golden.ticket builder.golden.ticket.info builder.golden.ticket.title builder.on.speedup builder.promo.golden.ticket builder.pass.challenge.complete builder.pass.button builder.pass.challenges.button builder.pass.rewards.button builder.pass.reward.already.claimed builder.pass.reward.no.premium builder.pass.reward.cant.afford builder.challenge.description.swim builder.challenge.description.fly builder.challenge.description.walk builder.challenge.description.train builder.challenge.description.any.block builder.challenge.description.block.destroy builder.challenge.description.blueprint.block builder.challenge.description.blueprint.build builder.challenge.description.furniture.buy builder.challenge.description.drive builder.challenge.description.blueprint.earn builder.challenge.description.event.block builder.challenge.description.furniture.block builder.challenge.description.human.pet builder.challenge.description.mounted builder.challenge.description.nature.block builder.challenge.description.pumpkin.block builder.challenge.description.level.reach builder.challenge.description.snow.block builder.challenge.description.special.block builder.challenge.description.special.legendary.block builder.challenge.description.standard.block builder.challenge.description.use.interactive builder.challenge.description.event.score builder.challenge.description.skin.change builder.pass.challenge.description.recruit2 builder.pass.title.AnyBlock2000 builder.pass.title.BlockDestroy1000 builder.pass.title.BlueprintFill1000 builder.pass.title.BuildBlueprint5 builder.pass.title.BuildBlueprint10 builder.pass.title.BuyFurniture5 builder.pass.title.Drive1000 builder.pass.title.Earn50SoftBlueprint builder.pass.title.EventBlock400 builder.pass.title.Flying300 builder.pass.title.FurnitureBlock5 builder.pass.title.HumanPet10 builder.pass.title.Mounted1000 builder.pass.title.NatureBlock200 builder.pass.title.PumpkinBlock50 builder.pass.title.ReachLevel10 builder.pass.title.SnowBlock100 builder.pass.title.SpecialBlock10 builder.pass.title.SpecialLegendaryBlock5 builder.pass.title.StandardBlock400 builder.pass.title.Swimming500 builder.pass.title.Train300 builder.pass.title.UseInteractive10 builder.pass.title.WeeklyEventScore500 builder.pass.challenge.title.AnyBlock50 builder.pass.challenge.title.BuildBlueprint1 builder.pass.challenge.title.SkinChange1 builder.pass.challenge.title.Walk500 builder.pass.challenge.title.WeeklyEventScore100 builder.pass.challenge.title.recruit2 menu.back garage.upgrade pickup.generation.next.in max.lvl combat.tutorial.step.0 combat.tutorial.step.1 combat.tutorial.step.2 combat.tutorial.step.3 combat.tutorial.step.4 combat.tutorial.step.5 combat.tutorial.step.6 combat.tutorial.step.7 combat.tutorial.step.8 combat.tutorial.step.9 watch.ad.to.get";
        String wroteTag = SPUtil.getString(context, tagKey, "");
        if (!wroteTag.isEmpty()) {
            return;
        }
        String[] keyArr = keyList.split(" ");
        try {
            String jsonStr = AssetsResourceUtils.getAssetsToString(context, "game.json");
            JSONObject jsonObject = new JSONObject(jsonStr);
            for (String key : keyArr) {
                String value = jsonObject.optString(key, "");
                if (!value.isEmpty()) {
                    SPUtil.putString(context, "string.prefix." + key, value);
                }
            }
            SPUtil.putInt(context, readLocalTag, 1);
            SPUtil.putString(context, tagKey, keyList);

            String settingsStr = AssetsResourceUtils.getAssetsToString(context, "settings.json");
            JSONObject jsonSettings = new JSONObject(settingsStr);
            Iterator<String> iterator = jsonSettings.keys();
            while (iterator.hasNext()) {
                String key = iterator.next();
                String value = jsonSettings.getString(key);
                SPUtil.putString(context, "string.prefix." + key, value);
            }
            SPUtil.putInt(context, settingskey, 1);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
